<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
    <script type="text/javascript" src="/js/jquery-1.11.1.js"></script>
    <script type="text/javascript" src="/js/bootstrap.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="/css/style.css"/>
    <style>
        label span {
            color: #ff0000;
            padding-right: 5px;
        }
    </style>
</head>

<body>
<h2>添加商品</h2>
<form id="myForm" class="form-horizontal" method="post" action="/team">
    <div class="form-group">
        <label class="col-sm-1 control-label"><span>*</span>编号</label>
        <div class="col-sm-9">
            <input required="required" name="p_id" class="form-control" placeholder="请输入 商品编号"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label"><span>*</span>名称</label>
        <div class="col-sm-9">
            <input required="" name="p_name" class="form-control" placeholder="请输入 商品名称"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label">类型</label>
        <div class="col-sm-9">
            <input name="p_type" class="form-control" placeholder="请输入 商品类型(空调、冰箱、洗衣机...)"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label">品牌</label>
        <div class="col-sm-9">
            <input name="p_brand" class="form-control" placeholder="请输入 商品品牌"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label"><span>*</span>条形码</label>
        <div class="col-sm-9">
            <input name="p_code" class="form-control" placeholder="请输入 条形码"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label"><span>*</span>规格</label>
        <div class="col-sm-9">
            <input name="p_rule" class="form-control" placeholder="请输入 商品规格"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-1 control-label">备注</label>
        <div class="col-sm-9">
            <input name="p_remarks" class="form-control"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-1 control-label">成本价</label>
        <div class="col-sm-9">
            <input name="p_cost" class="form-control"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-1 control-label">零售价</label>
        <div class="col-sm-9">
            <input name="p_retail" class="form-control"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-1 control-label"></label>
        <div class="col-sm-9">
            <button id="btnAdd" type="button" class="btn btn-sm btn-info">提&nbsp;交</button>
            <button type="reset" class="btn btn-sm btn-warning">重&nbsp;置</button>
        </div>
    </div>

</form>

</body>
</html>
<script>
    $(function () {
        //提交按钮的单击事件
        $("#btnAdd").click(function () {
            $.ajax({
                type: "POST",
                url: "/product",
                data: $("#myForm").serialize(),
                dataType: "json",
                success: function (vo) {
                    if (vo.code == 200) {
                        alert("操作成功！");
                        window.location.href = "/pages/product/list.html";
                    } else {
                        alert("添加失败！" + vo.msg);
                    }
                }
            });
        });
    });
</script>